package com.mvd.app.ac2021.activitys;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.mvd.app.R;
import com.mvd.app.activity.BaseActivity;
import com.mvd.app.adapter.TianjinReportAdapter;
import com.mvd.app.application.BaseApplication;
import com.mvd.app.commons.CommonUtils;
import com.mvd.app.commons.DateUtil;
import com.mvd.app.commons.JsonUtil;
import com.mvd.app.commons.PDALogUtils;
import com.mvd.app.commons.SharedPreferencesUtils;
import com.mvd.app.commons.UtilsLog;
import com.mvd.app.model.TianjinReportModel;
import com.mvd.app.model.TianjinReportModel2;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class TianjinReportActivity extends BaseActivity {
    @BindView(R.id.ac_tianjin_report_carPlate)
    TextView acTianjinReportCarPlate;
    @BindView(R.id.ac_tianjin_report_lv)
    ListView acTianjinReportLv;
    @BindView(R.id.ac_tianjin_report_bh)
    TextView acTianjinReportBh;
    @BindView(R.id.ac_tianjin_report_cllx)
    TextView acTianjinReportCllx;
    @BindView(R.id.ac_tianjin_report_clxh)
    TextView acTianjinReportClxh;
    @BindView(R.id.ac_tianjin_report_dz)
    TextView acTianjinReportDz;
    @BindView(R.id.ac_tianjin_report_tv1)
    TextView acTianjinReportTv1;
    @BindView(R.id.ac_tianjin_report_photo1)
    ImageView acTianjinReportPhoto1;
    @BindView(R.id.ac_tianjin_report_tv2)
    TextView acTianjinReportTv2;
    @BindView(R.id.ac_tianjin_report_photo2)
    ImageView acTianjinReportPhoto2;
    @BindView(R.id.ac_tianjin_report_tv3)
    TextView acTianjinReportTv3;
    @BindView(R.id.ac_tianjin_report_photo3)
    ImageView acTianjinReportPhoto3;
    @BindView(R.id.ac_tianjin_report_tv4)
    TextView acTianjinReportTv4;
    @BindView(R.id.ac_tianjin_report_photo4)
    ImageView acTianjinReportPhoto4;
    @BindView(R.id.ac_tianjin_report_tv5)
    TextView acTianjinReportTv5;
    @BindView(R.id.ac_tianjin_report_photo5)
    ImageView acTianjinReportPhoto5;
    @BindView(R.id.ac_tianjin_report_tv6)
    TextView acTianjinReportTv6;
    @BindView(R.id.ac_tianjin_report_photo6)
    ImageView acTianjinReportPhoto6;
    @BindView(R.id.ac_tianjin_report_tv7)
    TextView acTianjinReportTv7;
    @BindView(R.id.ac_tianjin_report_photo7)
    ImageView acTianjinReportPhoto7;
    @BindView(R.id.ac_tianjin_report_ll1)
    LinearLayout acTianjinReportLl1;
    @BindView(R.id.ac_tianjin_report_ll2)
    LinearLayout acTianjinReportLl2;
    @BindView(R.id.ac_tianjin_report_ll3)
    LinearLayout acTianjinReportLl3;
    @BindView(R.id.ac_tianjin_report_ll4)
    LinearLayout acTianjinReportLl4;
    @BindView(R.id.ac_tianjin_report_ll5)
    LinearLayout acTianjinReportLl5;
    @BindView(R.id.ac_tianjin_report_ll6)
    LinearLayout acTianjinReportLl6;
    @BindView(R.id.ac_tianjin_report_ll7)
    LinearLayout acTianjinReportLl7;
    @BindView(R.id.photo_text1)
    TextView photoText1;
    @BindView(R.id.photo_text2)
    TextView photoText2;
    @BindView(R.id.photo_text3)
    TextView photoText3;
    @BindView(R.id.photo_text4)
    TextView photoText4;
    @BindView(R.id.photo_text5)
    TextView photoText5;
    @BindView(R.id.photo_text6)
    TextView photoText6;
    @BindView(R.id.photo_text7)
    TextView photoText7;
    private TianjinReportModel tianjinReportModel;
    private List<TianjinReportModel> tianjinReportModels;
    private TianjinReportModel2 tianjinReportModel2;
    private List<TianjinReportModel2> tianjinReportModels2;
    private String plateNo;
    private List<String> zpbhList = new ArrayList<>();
    //    private List<String> zpList = new ArrayList<>();
//    private List<byte[]> zpByteList = new ArrayList<>();
    private TianjinReportActivity instances;
    private TianjinReportAdapter adapter;
    int size;
    String bh;
    int index;
    boolean isNewPlat = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tianjin_report);
        setTopTitle("查询车辆报告");
        setBackBtn();
        ButterKnife.bind(this);
        instances = this;
        String logStrf = "\n" + "onCreate-----天津查询车辆报告-----TianjinReportActivity--" + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
        String finalResult = getIntent().getStringExtra("tianjinReport");
        plateNo = getIntent().getStringExtra("plateNo");
        isNewPlat = getIntent().getBooleanExtra("isNewPlat", false);
//        String finalResult = "";
        if (!TextUtils.isEmpty(finalResult) && !"[[]]".equals(finalResult) && !"[{}]".equals
                (finalResult) && !"[]".equals(finalResult)) {
            if (isNewPlat) {
                JSONArray jsonArray = null;
                try {
                    jsonArray = new JSONArray(getIntent().getStringExtra("tianjinReport"));
                    Log.e("------------", "jsonArray===" + jsonArray);
                    tianjinReportModel2 = new TianjinReportModel2();
                    tianjinReportModels2 = new ArrayList<TianjinReportModel2>();
                    tianjinReportModels2 = JsonUtil.stringToArray(finalResult,
                            TianjinReportModel2[].class);
                    List<String> ggsxrqList = new ArrayList<>();
                    for (int i = 0; i < tianjinReportModels2.get(0).getResult().size(); i++) {
                        ggsxrqList.add(tianjinReportModels2.get(0).getResult().get(i).getZcggObj().getGgsxrq().substring(0, 10));
                    }
                    String logStr68 = "ggsxrqList====" + ggsxrqList.toString();
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr68.getBytes());
                    if (ggsxrqList.size() > 0) {
                        String logStr9 = "TianjinReportActivity--DateUtil.theLatestDate(ggsxrqList)==-=" + DateUtil.theLatestDate(ggsxrqList);
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr9.getBytes());
                        for (int i = 0; i < ggsxrqList.size(); i++) {
                            if (ggsxrqList.get(i).equals(DateUtil.theLatestDate(ggsxrqList))) {
                                index = i;
                            }
                        }
                        initDate2(index);
                        size = tianjinReportModels2.get(0).getResult().get(index).getGgzpList().size();
                        if (size > 0) {
                            bh = tianjinReportModels2.get(0).getResult().get(index).getGgzpList().get(0).getBh();
                            String logStr = "天津--查询车辆报告--size()===" + size + "------bh====" +
                                    tianjinReportModels2.get(0).getResult().get(index).getGgzpList().get(0).getBh();
                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                            List<Integer> sxhList = new ArrayList<>();
                            for (int i = 0; i < size; i++) {
                                sxhList.add(tianjinReportModels2.get(0).getResult().get(index).getGgzpList().get(i).getSxh());
                            }
                            String logStr7 = "天津--查询车辆报告--sxhList===" + sxhList.toString();
                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr7.getBytes());
                            for (int i = 0; i < sxhList.size(); i++) {
                                int sxh = sxhList.get(i);
                                String logStr3 = "sxh====" + sxh;
                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr3.getBytes());
                                getPhoto2(sxh, bh, i, "");
                            }
                        } else {
                            String logStr = "天津--查询车辆报告--size()===0";
                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                            Toast.makeText(instances, "未查询到照片", Toast.LENGTH_LONG).show();
                        }
                    }
                } catch (Exception e) {
                    String logStr = "\n" + "Exception-----天津查询车辆报告-----TianjinReportActivity--" + e + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                }
            } else {
                JSONObject jsonObject = null;
                try {
                    jsonObject = new JSONObject(getIntent().getStringExtra("tianjinReport"));
                    Log.e("------------", "jsonobject===" + jsonObject);
//            if (jsonObject.has("vehicle")) {
                    String info = "[" + getIntent().getStringExtra("tianjinReport") + "]";
                    tianjinReportModel = new TianjinReportModel();
                    tianjinReportModels = new ArrayList<TianjinReportModel>();
                    tianjinReportModels = JsonUtil.stringToArray(info,
                            TianjinReportModel[].class);
                    bh = tianjinReportModels.get(0).getVehicle().get(1).getBh();
                    initDate();
                    if (jsonObject.has("photodes")) {
                        finalResult = "[{\"vehicle\":" + jsonObject.get("vehicle") + ",\"photodes\":" + jsonObject.get("photodes") + "}]";
                        Log.e("------------", "finalResult===" + finalResult);
                        tianjinReportModel = new TianjinReportModel();
                        tianjinReportModels = new ArrayList<TianjinReportModel>();
                        tianjinReportModels = JsonUtil.stringToArray(finalResult,
                                TianjinReportModel[].class);
                        bh = tianjinReportModels.get(0).getVehicle().get(1).getBh();
                        Log.e("------------------", "111111111111111111111111");
                        size = tianjinReportModels.get(0).getPhotodes().size();
                        String logStr = "天津--查询车辆报告--size()===" + size + "------bh====" + bh;
                        Log.e("------------------", logStr);
                        Log.e("------------------", "2222222222222222222222222");
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        zpbhList = new ArrayList<>();
                        for (int i = 0; i < size; i++) {
                            String zpbh = tianjinReportModels.get(0).getPhotodes().get(i).getZpbh();
                            String bh2 = tianjinReportModels.get(0).getPhotodes().get(i).getBh();
                            String logStr33 = "zpbh::" + zpbh + "-----bh2::" + bh2 + "----bh===" + bh;
                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr33.getBytes());
                            if (!bh2.equals(bh)) {
                                continue;
                            }
                            zpbhList.add(zpbh + " ");
                        }
                        String logStr55 = "zpbhList.size====" + zpbhList.size() + "------zpbhList====" + zpbhList;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr55.getBytes());
                        String logStr2 = "zpbhList====" + zpbhList;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                        if (zpbhList.size() > 0) {
                            for (int i = 0; i < zpbhList.size(); i++) {
                                String zpbh = zpbhList.get(i).trim();
                                String logStr3 = "zpbh====" + zpbh;
                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr3.getBytes());
                                getPhoto2(0, "", i, zpbh);
                            }
                        } else {
                            Toast.makeText(instances, "未查询到照片", Toast.LENGTH_LONG).show();
                        }
                    } else {
                        Toast.makeText(instances, "未查询到车辆照片信息", Toast.LENGTH_LONG).show();
                    }
//            } else {
//                Toast.makeText(instances, "未查询到车辆信息", Toast.LENGTH_LONG).show();
//            }


                } catch (Exception e) {
                    String logStr = "\n" + "Exception-----天津查询车辆报告-----TianjinReportActivity--" + e + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                }
            }

        } else {
            Toast.makeText(instances, "未查询到车辆信息", Toast.LENGTH_LONG).show();
        }

    }

    private void initDate() {
        bh = tianjinReportModels.get(0).getVehicle().get(1).getBh();
        String clxh = tianjinReportModels.get(0).getVehicle().get(1).getClxh();
        String cllx = tianjinReportModels.get(0).getVehicle().get(1).getCllx();
        String scdz = tianjinReportModels.get(0).getVehicle().get(1).getScdz();
        acTianjinReportCarPlate.setText(plateNo);
        acTianjinReportBh.setText(bh);
        acTianjinReportCllx.setText(cllx);
        acTianjinReportClxh.setText(clxh);
        acTianjinReportDz.setText(scdz);
    }

    private void initDate2(int index) {
        String bh = tianjinReportModels2.get(0).getResult().get(index).getZcggObj().getBh();
        String clxh = tianjinReportModels2.get(0).getResult().get(index).getZcggObj().getClxh();
        String cllx = tianjinReportModels2.get(0).getResult().get(index).getZcggObj().getCllx();
        String scdz = tianjinReportModels2.get(0).getResult().get(index).getZcggObj().getScdz();
        acTianjinReportCarPlate.setText(plateNo);
        acTianjinReportBh.setText(bh);
        acTianjinReportCllx.setText(cllx);
        acTianjinReportClxh.setText(clxh);
        acTianjinReportDz.setText(scdz);
    }

//    private void getPhoto(String zpbh, int index) {
//        GetPhotoModel model = new GetPhotoModel();
//        model.setZpbh(zpbh);
//        String jsonStr = JsonUtil.toJson(model);
//        String logStr = "\n" + "天津---查询照片---" + "\n" +
//                "json::" + jsonStr + "\n" +
//                "URL::" + SharedPreferencesUtils.getIP(instances) + QUETY_PICTURE;
//        Log.e("------------------", logStr);
//        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + QUETY_PICTURE)
//                .tag(this)
//                .upJson(jsonStr)
//                .execute(new StringCallback() {
//                    @Override
//                    public void onStart(Request<String, ? extends Request> request) {
//                        super.onStart(request);
////                        CommonUtils.showLoadingDialog(instances, "加载中...");
//                    }
//
//                    @Override
//                    public void onSuccess(Response<String> response) {
//                        String result = response.body().trim();
//                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
//                        UtilsLog.e("天津---查询照片-result==" + result);
//                        UtilsLog.e("天津---查询照片-newResult==" + newResult);
//                        String logStr = "\n" + "天津---查询照片----请求成功" + "\n" +
//                                "result::" + response.body() + "\n" + "newResult::" + newResult + "\n";
//                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
////                        if (!TextUtils.isEmpty(newResult) && !"[[]]".equals(newResult) && !"[{}]".equals
////                                (newResult) && !"[]".equals(result)) {
////                        }
//                        try {
//                            JSONObject jsonObject = new JSONObject(newResult);
//                            String zp = jsonObject.getJSONObject("root").getJSONObject("body").getJSONObject("photo").getString("zp");
//                            byte[] decodedString = Base64.decode(zp, Base64.DEFAULT);
//                            zpList.add(index, zp);
//                            zpByteList.add(index, decodedString);
//                            String logStr2 = "\n" + "天津---查询照片----请求成功" + "\n" +
//                                    "base64照片::" + zp + "\n" + "index::" + index + "-----zpList==" + zpList + "\n" + "-----zpByteList==" + zpByteList.toString();
//                            Log.e("tag", "天津---查询照片----base64照片====" + zp + "\n" + "index::" + index + "-----zpList==" + zpList + "\n" + "-----zpByteList==" + zpByteList.toString());
//                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
//                            if (zpByteList.size() == size) {
//                                String logStr3 = "天津--查询车辆报告--zpList===" + zpList;
//                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr3.getBytes());
//                                if (zpByteList != null && zpByteList.size() > 0) {
//                                    adapter = new TianjinReportAdapter(instances, tianjinReportModels, zpByteList);
//                                    acTianjinReportLv.setAdapter(adapter);
//                                    ListViewUtils.setListViewHeightBasedOnChildren(acTianjinReportLv);//为了解决ScrollView嵌套ListView时只显示一个item的高度的问题，需要动态设置ListView的高度
//                                }
//                            }
//                        } catch (JSONException e) {
//                            e.printStackTrace();
//                        }
//
//                    }
//
//                    @Override
//                    public void onError(Response<String> response) {
//                        super.onError(response);
//                        String logStr2 = "\n" + "天津---查询照片--onError" + "\n" +
//                                "result::" + response.body();
//                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
//                        UtilsLog.e("天津---查询照片-onError==" + response.body());
//                        CommonUtils.hideLoadingDialog(instances);
//                    }
//                });
//    }

    private void getPhoto2(int sxh, String bh, int index, String zpbh) {
        GetPhotoModel model = new GetPhotoModel();
        if (isNewPlat) {
            model.setBh(bh);
            model.setSxh(sxh);
            model.setIsNew("1");
        } else {
            model.setZpbh(zpbh);
        }
        Gson gson = new Gson();
        String jsonStr = gson.toJson(model);
        String logStr = "\n" + "天津---查询照片---" + "\n" +
                "json::" + jsonStr + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(instances) + QUETY_PICTURE;
        Log.e("------------------", logStr);
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + QUETY_PICTURE)
                .tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body().trim();
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("天津---查询照片-result==" + result);
                        UtilsLog.e("天津---查询照片-newResult==" + newResult);
                        String logStr = "\n" + "天津---查询照片----请求成功" + "\n" +
                                "result::" + response.body() + "\n" + "newResult::" + newResult + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        if (!TextUtils.isEmpty(newResult) && !"[[]]".equals(newResult) && !"[{}]".equals
//                                (newResult) && !"[]".equals(result)) {
//                        }
                        if (isNewPlat) {
                            try {
                                JSONArray jsonArray = new JSONArray(newResult);
                                String zp = jsonArray.getJSONObject(0).getJSONObject("result").getString("zp");
                                int sxh = jsonArray.getJSONObject(0).getJSONObject("result").getInt("sxh");
                                byte[] decodedString = Base64.decode(zp, Base64.DEFAULT);
                                //系统api加载，byte转bitmap
                                Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
                                if (index == 0) {
                                    acTianjinReportLl1.setVisibility(View.VISIBLE);
                                    acTianjinReportTv1.setText(sxh + " ");
                                    photoText1.setText("照片顺序号");
                                    acTianjinReportPhoto1.setImageBitmap(decodedByte);
//                                Glide.with(instances).load(decodedByte).into(acTianjinReportPhoto1);
                                } else if (index == 1) {
                                    acTianjinReportLl2.setVisibility(View.VISIBLE);
                                    acTianjinReportTv2.setText(sxh + " ");
                                    photoText2.setText("照片顺序号");
                                    acTianjinReportPhoto2.setImageBitmap(decodedByte);
                                } else if (index == 2) {
                                    acTianjinReportLl3.setVisibility(View.VISIBLE);
                                    acTianjinReportTv3.setText(sxh + " ");
                                    photoText3.setText("照片顺序号");
                                    acTianjinReportPhoto3.setImageBitmap(decodedByte);
                                } else if (index == 3) {
                                    acTianjinReportLl4.setVisibility(View.VISIBLE);
                                    acTianjinReportTv4.setText(sxh + " ");
                                    photoText4.setText("照片顺序号");
                                    acTianjinReportPhoto4.setImageBitmap(decodedByte);
                                } else if (index == 4) {
                                    acTianjinReportLl5.setVisibility(View.VISIBLE);
                                    acTianjinReportTv5.setText(sxh + " ");
                                    photoText5.setText("照片顺序号");
                                    acTianjinReportPhoto5.setImageBitmap(decodedByte);
                                } else if (index == 5) {
                                    acTianjinReportLl6.setVisibility(View.VISIBLE);
                                    acTianjinReportTv6.setText(sxh + " ");
                                    photoText6.setText("照片顺序号");
                                    acTianjinReportPhoto6.setImageBitmap(decodedByte);
                                } else if (index == 6) {
                                    acTianjinReportLl7.setVisibility(View.VISIBLE);
                                    acTianjinReportTv7.setText(sxh + " ");
                                    photoText7.setText("照片顺序号");
                                    acTianjinReportPhoto7.setImageBitmap(decodedByte);
                                }
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        } else {
                            try {
                                JSONObject jsonObject = new JSONObject(newResult);
                                String zp = jsonObject.getJSONObject("root").getJSONObject("body").getJSONObject("photo").getString("zp");
                                byte[] decodedString = Base64.decode(zp, Base64.DEFAULT);
                                //系统api加载，byte转bitmap
                                Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
//                            zpList.add(index, zp);
//                            zpByteList.add(index, decodedString);
//                            String logStr2 = "\n" + "天津---查询照片----请求成功" + "\n" +
//                                    "base64照片::" + zp + "\n" + "index::" + index + "-----zpList==" + zpList + "\n"
//                                    + "-----zpByteList==" + zpByteList.toString();
//                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                                if (index == 0) {
                                    acTianjinReportLl1.setVisibility(View.VISIBLE);
                                    acTianjinReportTv1.setText(zpbh);
                                    acTianjinReportPhoto1.setImageBitmap(decodedByte);
//                                Glide.with(instances).load(decodedByte).into(acTianjinReportPhoto1);
                                } else if (index == 1) {
                                    acTianjinReportLl2.setVisibility(View.VISIBLE);
                                    acTianjinReportTv2.setText(zpbh);
                                    acTianjinReportPhoto2.setImageBitmap(decodedByte);
                                } else if (index == 2) {
                                    acTianjinReportLl3.setVisibility(View.VISIBLE);
                                    acTianjinReportTv3.setText(zpbh);
                                    acTianjinReportPhoto3.setImageBitmap(decodedByte);
                                } else if (index == 3) {
                                    acTianjinReportLl4.setVisibility(View.VISIBLE);
                                    acTianjinReportTv4.setText(zpbh);
                                    acTianjinReportPhoto4.setImageBitmap(decodedByte);
                                } else if (index == 4) {
                                    acTianjinReportLl5.setVisibility(View.VISIBLE);
                                    acTianjinReportTv5.setText(zpbh);
                                    acTianjinReportPhoto5.setImageBitmap(decodedByte);
                                } else if (index == 5) {
                                    acTianjinReportLl6.setVisibility(View.VISIBLE);
                                    acTianjinReportTv6.setText(zpbh);
                                    acTianjinReportPhoto6.setImageBitmap(decodedByte);
                                } else if (index == 6) {
                                    acTianjinReportLl7.setVisibility(View.VISIBLE);
                                    acTianjinReportTv7.setText(zpbh);
                                    acTianjinReportPhoto7.setImageBitmap(decodedByte);
                                }

//                            if (zpByteList.size() == size) {
//                                if (zpByteList.size() == 0) {
//                                    Toast.makeText(instances, "未查询到照片", Toast.LENGTH_LONG).show();
//                                } else if (zpByteList.size() == 1) {
//                                    acTianjinReportLl1.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv1.setText(tianjinReportModels.get(0).getPhotodes().get(0).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(0)).into(acTianjinReportPhoto1);
//                                }else if (zpByteList.size() == 2){
//                                    acTianjinReportLl1.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv1.setText(tianjinReportModels.get(0).getPhotodes().get(0).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(0)).into(acTianjinReportPhoto1);
//                                    acTianjinReportLl2.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv2.setText(tianjinReportModels.get(0).getPhotodes().get(1).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(1)).into(acTianjinReportPhoto2);
//                                }else if (zpByteList.size() == 3){
//                                    acTianjinReportLl1.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv1.setText(tianjinReportModels.get(0).getPhotodes().get(0).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(0)).into(acTianjinReportPhoto1);
//                                    acTianjinReportLl2.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv2.setText(tianjinReportModels.get(0).getPhotodes().get(1).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(1)).into(acTianjinReportPhoto2);
//                                    acTianjinReportLl3.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv3.setText(tianjinReportModels.get(0).getPhotodes().get(2).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(2)).into(acTianjinReportPhoto3);
//                                }else if (zpByteList.size() == 4){
//                                    acTianjinReportLl1.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv1.setText(tianjinReportModels.get(0).getPhotodes().get(0).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(0)).into(acTianjinReportPhoto1);
//                                    acTianjinReportLl2.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv2.setText(tianjinReportModels.get(0).getPhotodes().get(1).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(1)).into(acTianjinReportPhoto2);
//                                    acTianjinReportLl3.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv3.setText(tianjinReportModels.get(0).getPhotodes().get(2).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(2)).into(acTianjinReportPhoto3);
//                                    acTianjinReportLl4.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv4.setText(tianjinReportModels.get(0).getPhotodes().get(3).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(3)).into(acTianjinReportPhoto4);
//                                }else if (zpByteList.size() == 5){
//                                    acTianjinReportLl1.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv1.setText(tianjinReportModels.get(0).getPhotodes().get(0).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(0)).into(acTianjinReportPhoto1);
//                                    acTianjinReportLl2.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv2.setText(tianjinReportModels.get(0).getPhotodes().get(1).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(1)).into(acTianjinReportPhoto2);
//                                    acTianjinReportLl3.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv3.setText(tianjinReportModels.get(0).getPhotodes().get(2).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(2)).into(acTianjinReportPhoto3);
//                                    acTianjinReportLl4.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv4.setText(tianjinReportModels.get(0).getPhotodes().get(3).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(3)).into(acTianjinReportPhoto4);
//                                    acTianjinReportLl5.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv5.setText(tianjinReportModels.get(0).getPhotodes().get(4).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(4)).into(acTianjinReportPhoto5);
//                                }else if (zpByteList.size() == 6){
//                                    acTianjinReportLl1.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv1.setText(tianjinReportModels.get(0).getPhotodes().get(0).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(0)).into(acTianjinReportPhoto1);
//                                    acTianjinReportLl2.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv2.setText(tianjinReportModels.get(0).getPhotodes().get(1).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(1)).into(acTianjinReportPhoto2);
//                                    acTianjinReportLl3.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv3.setText(tianjinReportModels.get(0).getPhotodes().get(2).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(2)).into(acTianjinReportPhoto3);
//                                    acTianjinReportLl4.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv4.setText(tianjinReportModels.get(0).getPhotodes().get(3).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(3)).into(acTianjinReportPhoto4);
//                                    acTianjinReportLl5.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv5.setText(tianjinReportModels.get(0).getPhotodes().get(4).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(4)).into(acTianjinReportPhoto5);
//                                    acTianjinReportLl6.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv6.setText(tianjinReportModels.get(0).getPhotodes().get(5).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(5)).into(acTianjinReportPhoto6);
//                                }else if (zpByteList.size() == 7){
//                                    acTianjinReportLl1.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv1.setText(tianjinReportModels.get(0).getPhotodes().get(0).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(0)).into(acTianjinReportPhoto1);
//                                    acTianjinReportLl2.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv2.setText(tianjinReportModels.get(0).getPhotodes().get(1).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(1)).into(acTianjinReportPhoto2);
//                                    acTianjinReportLl3.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv3.setText(tianjinReportModels.get(0).getPhotodes().get(2).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(2)).into(acTianjinReportPhoto3);
//                                    acTianjinReportLl4.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv4.setText(tianjinReportModels.get(0).getPhotodes().get(3).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(3)).into(acTianjinReportPhoto4);
//                                    acTianjinReportLl5.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv5.setText(tianjinReportModels.get(0).getPhotodes().get(4).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(4)).into(acTianjinReportPhoto5);
//                                    acTianjinReportLl6.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv6.setText(tianjinReportModels.get(0).getPhotodes().get(5).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(5)).into(acTianjinReportPhoto6);
//                                    acTianjinReportLl7.setVisibility(View.VISIBLE);
//                                    acTianjinReportTv7.setText(tianjinReportModels.get(0).getPhotodes().get(6).getZpbh());
//                                    Glide.with(instances).load(zpByteList.get(6)).into(acTianjinReportPhoto7);
//                                }
//                            }
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }

                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        String logStr2 = "\n" + "天津---查询照片--onError" + "\n" +
                                "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                        UtilsLog.e("天津---查询照片-onError==" + response.body());
                        CommonUtils.hideLoadingDialog(instances);
                    }
                });
    }

    private class GetPhotoModel {
        private String zpbh;
        private String bh;
        private int sxh;
        private String IsNew;

        @Override
        public String toString() {
            return "GetPhotoModel{" +
                    "zpbh='" + zpbh + '\'' +
                    ", bh='" + bh + '\'' +
                    ", sxh=" + sxh +
                    ", isNew='" + IsNew + '\'' +
                    '}';
        }

        public String getZpbh() {
            return zpbh;
        }

        public void setZpbh(String zpbh) {
            this.zpbh = zpbh;
        }

        public String getIsNew() {
            return IsNew;
        }

        public void setIsNew(String isNew) {
            this.IsNew = isNew;
        }

        public String getBh() {
            return bh;
        }

        public void setBh(String bh) {
            this.bh = bh;
        }

        public int getSxh() {
            return sxh;
        }

        public void setSxh(int sxh) {
            this.sxh = sxh;
        }
    }

    private class ZpModel {
        private String zp;

        @Override
        public String toString() {
            return "ZpModel{" +
                    "zp='" + zp + '\'' +
                    '}';
        }

        public String getZp() {
            return zp;
        }

        public void setZp(String zp) {
            this.zp = zp;
        }
    }

}
